<template>
    <a-tree-select style="min-width: 200px;"  :tree-data="options" :value="String(modelValue)" tree-default-expand-all allow-clear
        :field-names="{ label: 'title', value: 'id' }" @change="handleChange" placeholder="请选择组织" />
</template>

<script setup lang="ts">
import { getOrganizationList } from '@/api/system/organize/organization'

const props = defineProps<{
    modelValue: string | number
}>()

const emit = defineEmits(['update:modelValue'])

const options = ref([])

onMounted(async () => {
    const res = await getOrganizationList()
    options.value = res.lists
})

const handleChange = (value: string | number | null) => {
    console.log('handleChange value:', value)
    emit('update:modelValue', value || '')
}
</script>